<template>
  <CollapseContainer title="安全设置" :canExpan="false">
    <List>
      <template v-for="item in list" :key="item.key">
        <ListItem>
          <ListItemMeta>
            <template #title>
              {{ item.title }}
              <div class="extra" v-if="item.extra">
                {{ item.extra }}
              </div>
            </template>
            <template #description>
              <div>
                {{ item.description }}
                {{
                  item.key === 'userName'
                    ? userName
                    : item.key === 'phone'
                    ? phone
                    : item.key === 'email'
                    ? email
                    : '强'
                }}
              </div>
            </template>
          </ListItemMeta>
        </ListItem>
      </template>
    </List>
  </CollapseContainer>
</template>

<script lang="ts">
import { List } from 'ant-design-vue'
import { computed, defineComponent } from 'vue'
import { CollapseContainer } from '@/components/Container'
import { secureSettingList } from './data'
import { useUserStore } from '@/store/user'

export default defineComponent({
  components: {
    CollapseContainer,
    List,
    ListItem: List.Item,
    ListItemMeta: List.Item.Meta,
  },
  setup() {
    const userStore = useUserStore()

    const userName = computed(() => {
      const { userName } = userStore.getUserInfo
      return userName
    })

    const phone = computed(() => {
      const { phone } = userStore.getUserInfo
      return phone
    })

    const email = computed(() => {
      const { email } = userStore.getUserInfo
      return email
    })

    return {
      list: secureSettingList,
      userName,
      phone,
      email,
    }
  },
})
</script>

<style lang="less" scoped>
.extra {
  float: right;
  margin-top: 10px;
  margin-right: 30px;
  font-weight: normal;
  color: #1890ff;
  cursor: pointer;
}
</style>
